package cn.zl.GB28181.utils;

import java.util.Collection;

public class ByteUtils {

    public static byte[] toArray(Collection<? extends Number> collection) {
        Object[] boxedArray = collection.toArray();
        int len = boxedArray.length;
        byte[] array = new byte[len];

        for (int i = 0; i < len; ++i) {
            Object item = boxedArray[i];
            if(item == null){
                throw new NullPointerException();
            }
            array[i] = ((Number) boxedArray[i]).byteValue();
        }

        return array;
    }

}
